import { computed, reactive, ref } from "vue";
import { tableColumnMap } from "../data";

export default function InitHook() {
  const activeKey = ref<string>("1");
  const tableRef = ref<any>(null);
  const pageStat = ref<Base.GeneraDataType>({
    "1": 0,
    "2": 0,
    "3": 0,
    "4": 0
  });
  const searchForm = reactive<WorkOrder.SearchForm>({
    pageNum: 1,
    pageSize: 100,
    total: 0,
    beforePageNum: 2,
    workOrderNo: "",
    depositTime: [],
    waybillNumList: "",
    questionTypeList: [],
    shipmentLimit: undefined,
    outWarehouseBrokerIdList: [],
    selectStatusList: [],
    createByList: [],
    channelIdList: [],
    bizIdList: []
  });
  const tableData = ref<Array<WorkOrder.ListRows>>([]);
  const drawerOpts = reactive<Base.DrawerOpts>({
    title: "",
    width: "520px",
    component: "",
    visible: false,
    type: 1,
    passData: {}
  });
  const dialogOpts = reactive<Base.DialogOpts>({
    title: "",
    width: "520px",
    component: "",
    visible: false,
    type: 1,
    passData: {}
  });

  const tableColumn = computed<Array<SuperTable.NestTableColumnItem | SuperTable.TableCoulmnItem>>(() => {
    return tableColumnMap[activeKey.value] || [];
  });
  //   const getPopupContainer = () => document.querySelector(".nav-header-page");
  return {
    searchForm,
    tableData,
    drawerOpts,
    activeKey,
    pageStat,
    tableRef,
    tableColumn,
    dialogOpts
    // getPopupContainer
  };
}
